/**
 * Mock plugin for development and production.
 * https://github.com/anncwb/vite-plugin-mock
 */
import type {Plugin} from 'vite'
import {viteMockServe} from 'vite-plugin-mock'

export function configMockPlugin(
    useMock: string = "true",
): Plugin | null {
    return useMock
        ? viteMockServe({
            mockPath: "./src/api/serve",
            supportTs: true,
            watchFiles: true,
            ignore: (fileName) => {
                const pathArray = fileName.split("/")
                // console.log(fileName + " ===> " + (pathArray[0] === "response"))
                return (pathArray[0] === "response")
            },
        })
        : null
}
